package main

import (
	"fmt"
	"time"
)

func work(i int, c chan int) {
	for {
		n := <-c
		fmt.Printf("Worker %d received number %d\n", i, n)
	}
}

func Work(id int, c chan int) {
	for n := range c {
		fmt.Printf("Worker %d received number %d", id, n)
	}
}

func NewWorkerWithChannel(id int) chan<- int {
	c := make(chan int)
	go Work(id, c)
	return c
}

func main() {
	var cs [10]chan int
	for i := 0; i < 10; i++ {
		cs[i] = make(chan int)
		go work(i, cs[i])
	}
	for i := 0; i < 10; i++ {
		cs[i] <- i
	}
	time.Sleep(time.Second)
}
